# -*- encoding=utf8 -*-
__author__ = "Bryan.Chen"

from airtest.core.api import *

auto_setup(__file__)

from poco.drivers.std import StdPoco
poco = StdPoco()

using("../FlowTest.air")
import FlowTest

class Login_SignIn(FlowTest.BaseTestCase):

    def __init__(self):
        print("%s __init__" % (__file__))
    
    def runTest(self, args):
        
        signInLayer = poco("SignInLayer")
        if not signInLayer.exists():
            return True
        
        btnSign = signInLayer.offspring("sign_btn")
        btnClose = signInLayer.offspring("close_btn")
        
        if btnSign.attr("enabled") and btnSign.attr("visible"):
            self.clickButton(btnSign)
        else:
            self.clickButton(btnClose)
        
        sleep(1.0)
        
        receiveRewardLayer = poco("ReceiveRewardLayer")
        if receiveRewardLayer.exists():
            btnReceive = receiveRewardLayer.offspring("receive")
            self.clickButton(btnReceive)
        return True
                       
_instance = Login_SignIn()
runTest = _instance.runTest
    